From: Brad Jorsch Date: Fri, 21 Jun 2013 15:46:29 +0000 (-0400) Subject: API: Fix imageinfo iiurlheight on audio files X-Git-Tag: 1.31.0-rc.0~19368^2 X-Git-Url: http://git.cyclocoop.org/%27%20.%20%24prefix%20.%20Wiki::transformTitleToURI%28%24matches%5B1%5D%29%20.%20%27?a=commitdiff_plain;h=0f09d8ed2716d5e5da299b2380a0a4e06f677f05;p=lhc%2Fweb%2Fwiklou.git API: Fix imageinfo iiurlheight on audio files When iiurlheight is given without iiurlwidth, we want to limit the thumbnail by just the height. MediaWiki's file classes don't really support this, though, so we pass the image's full width as the limiting width to achieve the same effect. However, this fails for audio files where $file->getWidth() returns 0, but we can still get a thumbnail of a placeholder image. In that situation, we should just choose an arbitrary non-zero limiting width. Change-Id: I4318a06a96265d39e39e90cc706d49a1c3b6e8e3 --- diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 4849f40b83..fedf860476 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -231,10 +231,18 @@ class ApiQueryImageInfo extends ApiQueryBase { * @return Array of parameters for transform. */ protected function mergeThumbParams( $image, $thumbParams, $otherParams ) { + global $wgThumbLimits; if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) { - // Populate the width with the image's width, so only the height restriction applies - $thumbParams['width'] = $image->getWidth(); + // We want to limit only by height in this situation, so pass the + // image's full width as the limiting width. But some file types + // don't have a width of their own, so pick something arbitrary so + // thumbnailing the default icon works. + if ( $image->getWidth() <= 0 ) { + $thumbParams['width'] = max( $wgThumbLimits ); + } else { + $thumbParams['width'] = $image->getWidth(); + } } if ( !$otherParams ) {